<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>BadgerDB: badgerdb::Page Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">BadgerDB
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Friends</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="namespacebadgerdb.html">badgerdb</a>      </li>
      <li class="navelem"><a class="el" href="classbadgerdb_1_1_page.html">Page</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-attribs">Static Public Attributes</a> &#124;
<a href="#friends">Friends</a>  </div>
  <div class="headertitle">
<div class="title">badgerdb::Page Class Reference</div>  </div>
</div><!--header-->
<div class="contents">
<!-- doxytag: class="badgerdb::Page" -->
<p>Class which represents a fixed-size database page containing records.  
 <a href="classbadgerdb_1_1_page.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="page_8h_source.html">page.h</a>&gt;</code></p>

<p><a href="classbadgerdb_1_1_page-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#a1e4a3930a92ed6e71ffd253cf224379a">Page</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structbadgerdb_1_1_record_id.html">RecordId</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#ad0b1e85fe7849fb767dd8c21a8053cf4">insertRecord</a> (const std::string &amp;record_data)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#a77b352920c3e66384317bbcdcd900d99">getRecord</a> (const <a class="el" href="structbadgerdb_1_1_record_id.html">RecordId</a> &amp;record_id) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#ae24e3f6076d6c0a18d4dd2014d540bab">updateRecord</a> (const <a class="el" href="structbadgerdb_1_1_record_id.html">RecordId</a> &amp;record_id, const std::string &amp;record_data)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">deleteRecord</a> (const <a class="el" href="structbadgerdb_1_1_record_id.html">RecordId</a> &amp;record_id)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#a35bf91df5caa67a606681519740848b0">hasSpaceForRecord</a> (const std::string &amp;record_data) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">std::uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#af3d324b5aae656030465e213e86e2070">getFreeSpace</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#af55a0b44876bff4d513bdbed8bc8c5a3">page_number</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#a8050c219873e6b1d51aec2adbea8a507">next_page_number</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classbadgerdb_1_1_page_iterator.html">PageIterator</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#aa0fdb281074cd60cb1f1d6ea6d620772">begin</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classbadgerdb_1_1_page_iterator.html">PageIterator</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#a8e78cba69bef682a5427932485da4608">end</a> ()</td></tr>
<tr><td colspan="2"><h2><a name="pub-static-attribs"></a>
Static Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const std::size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#ae92d52803502854f97309bae2c14ea55">SIZE</a> = 8192</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const std::size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#a74057ec71412352ef0aa5913bbebed25">DATA_SIZE</a> = <a class="el" href="classbadgerdb_1_1_page.html#ae92d52803502854f97309bae2c14ea55">SIZE</a> - sizeof(<a class="el" href="structbadgerdb_1_1_page_header.html">PageHeader</a>)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const <a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#a785a1e756d47fb7f8f3603a3fe8ffcef">INVALID_NUMBER</a> = 0</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const <a class="el" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_page.html#a4013fab43df72bc52931241575736353">INVALID_SLOT</a> = 0</td></tr>
<tr><td colspan="2"><h2><a name="friends"></a>
Friends</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a68d15876ad188b7628261b12d0eac8aa"></a><!-- doxytag: member="badgerdb::Page::File" ref="a68d15876ad188b7628261b12d0eac8aa" args="" -->
class&#160;</td><td class="memItemRight" valign="bottom"><b>File</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae93be65f49fbfeb5716a90719b8c4cb7"></a><!-- doxytag: member="badgerdb::Page::PageIterator" ref="ae93be65f49fbfeb5716a90719b8c4cb7" args="" -->
class&#160;</td><td class="memItemRight" valign="bottom"><b>PageIterator</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a724e730c198a7a3d941f08f9653f8154"></a><!-- doxytag: member="badgerdb::Page::PageTest" ref="a724e730c198a7a3d941f08f9653f8154" args="" -->
class&#160;</td><td class="memItemRight" valign="bottom"><b>PageTest</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aaf5d48a87d5c9424661d35cc89243a13"></a><!-- doxytag: member="badgerdb::Page::BufferTest" ref="aaf5d48a87d5c9424661d35cc89243a13" args="" -->
class&#160;</td><td class="memItemRight" valign="bottom"><b>BufferTest</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Class which represents a fixed-size database page containing records. </p>
<p>A page is a fixed-size unit of data storage. Each page holds zero or more records, which consist of arbitrary binary data. Records are placed into slots and identified by a <a class="el" href="structbadgerdb_1_1_record_id.html" title="Identifier for a record in a page.">RecordId</a>. Although a record's actual contents may be moved on the page, accessing a record by its slot is consistent.</p>
<dl class="warning"><dt><b>Warning:</b></dt><dd>This class is not threadsafe. </dd></dl>

<p>Definition at line <a class="el" href="page_8h_source.html#l00107">107</a> of file <a class="el" href="page_8h_source.html">page.h</a>.</p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a1e4a3930a92ed6e71ffd253cf224379a"></a><!-- doxytag: member="badgerdb::Page::Page" ref="a1e4a3930a92ed6e71ffd253cf224379a" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classbadgerdb_1_1_page.html#a1e4a3930a92ed6e71ffd253cf224379a">badgerdb::Page::Page</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Constructs a new, uninitialized page. </p>

<p>Definition at line <a class="el" href="page_8cpp_source.html#l00019">19</a> of file <a class="el" href="page_8cpp_source.html">page.cpp</a>.</p>
<div class="fragment"><pre class="fragment">           {
  initialize();
}
</pre></div>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="aa0fdb281074cd60cb1f1d6ea6d620772"></a><!-- doxytag: member="badgerdb::Page::begin" ref="aa0fdb281074cd60cb1f1d6ea6d620772" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classbadgerdb_1_1_page_iterator.html">PageIterator</a> <a class="el" href="classbadgerdb_1_1_page.html#aa0fdb281074cd60cb1f1d6ea6d620772">badgerdb::Page::begin</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns an iterator at the first record in the page.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>Iterator at first record of page. </dd></dl>

<p>Definition at line <a class="el" href="page_8cpp_source.html#l00196">196</a> of file <a class="el" href="page_8cpp_source.html">page.cpp</a>.</p>
<div class="fragment"><pre class="fragment">                         {
  <span class="keywordflow">return</span> PageIterator(<span class="keyword">this</span>);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a1bc17754b4ed548f8520a6274b3a4202"></a><!-- doxytag: member="badgerdb::Page::deleteRecord" ref="a1bc17754b4ed548f8520a6274b3a4202" args="(const RecordId &amp;record_id)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">badgerdb::Page::deleteRecord</a> </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="structbadgerdb_1_1_record_id.html">RecordId</a> &amp;&#160;</td>
          <td class="paramname"><em>record_id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Deletes the record with the given ID. <a class="el" href="classbadgerdb_1_1_page.html" title="Class which represents a fixed-size database page containing records.">Page</a> is compacted upon delete to ensure that data of all records is contiguous. Slot array is compacted if the slot deleted is at the end of the slot array.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">record_id</td><td>ID of the record to delete. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="page_8cpp_source.html#l00066">66</a> of file <a class="el" href="page_8cpp_source.html">page.cpp</a>.</p>
<div class="fragment"><pre class="fragment">                                                 {
  <a class="code" href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">deleteRecord</a>(record_id, <span class="keyword">true</span> <span class="comment">/* allow_slot_compaction */</span>);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a8e78cba69bef682a5427932485da4608"></a><!-- doxytag: member="badgerdb::Page::end" ref="a8e78cba69bef682a5427932485da4608" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classbadgerdb_1_1_page_iterator.html">PageIterator</a> <a class="el" href="classbadgerdb_1_1_page.html#a8e78cba69bef682a5427932485da4608">badgerdb::Page::end</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns an iterator representing the record after the last record in the page. This iterator should not be dereferenced.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>Iterator representing record after the last record in the page. </dd></dl>

<p>Definition at line <a class="el" href="page_8cpp_source.html#l00200">200</a> of file <a class="el" href="page_8cpp_source.html">page.cpp</a>.</p>
<div class="fragment"><pre class="fragment">                       {
  <span class="keyword">const</span> RecordId&amp; end_record_id = {<a class="code" href="classbadgerdb_1_1_page.html#af55a0b44876bff4d513bdbed8bc8c5a3">page_number</a>(), <a class="code" href="classbadgerdb_1_1_page.html#a4013fab43df72bc52931241575736353">Page::INVALID_SLOT</a>};
  <span class="keywordflow">return</span> PageIterator(<span class="keyword">this</span>, end_record_id);
}
</pre></div>
</div>
</div>
<a class="anchor" id="af3d324b5aae656030465e213e86e2070"></a><!-- doxytag: member="badgerdb::Page::getFreeSpace" ref="af3d324b5aae656030465e213e86e2070" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">std::uint16_t <a class="el" href="classbadgerdb_1_1_page.html#af3d324b5aae656030465e213e86e2070">badgerdb::Page::getFreeSpace</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns this page's free space in bytes.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>Free space in bytes. </dd></dl>

<p>Definition at line <a class="el" href="page_8h_source.html#l00185">185</a> of file <a class="el" href="page_8h_source.html">page.h</a>.</p>
<div class="fragment"><pre class="fragment">                                   { <span class="keywordflow">return</span> header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a3af3c066d7651294fb3aae104f404648">free_space_upper_bound</a> -
                                              header_.<a class="code" href="structbadgerdb_1_1_page_header.html#ac71c5a9b3b8644da0ea827f5bd4c5742">free_space_lower_bound</a>; }
</pre></div>
</div>
</div>
<a class="anchor" id="a77b352920c3e66384317bbcdcd900d99"></a><!-- doxytag: member="badgerdb::Page::getRecord" ref="a77b352920c3e66384317bbcdcd900d99" args="(const RecordId &amp;record_id) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">std::string <a class="el" href="classbadgerdb_1_1_page.html#a77b352920c3e66384317bbcdcd900d99">badgerdb::Page::getRecord</a> </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="structbadgerdb_1_1_record_id.html">RecordId</a> &amp;&#160;</td>
          <td class="paramname"><em>record_id</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns the record with the given ID. Returned data is a copy of what is stored on the page; use updateRecord to change it.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classbadgerdb_1_1_page.html#ae24e3f6076d6c0a18d4dd2014d540bab">updateRecord</a> </dd></dl>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">record_id</td><td>ID of the record to return. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The record. </dd></dl>

<p>Definition at line <a class="el" href="page_8cpp_source.html#l00043">43</a> of file <a class="el" href="page_8cpp_source.html">page.cpp</a>.</p>
<div class="fragment"><pre class="fragment">                                                         {
  validateRecordId(record_id);
  <span class="keyword">const</span> PageSlot&amp; slot = getSlot(record_id.slot_number);
  <span class="keywordflow">return</span> data_.substr(slot.item_offset, slot.item_length);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a35bf91df5caa67a606681519740848b0"></a><!-- doxytag: member="badgerdb::Page::hasSpaceForRecord" ref="a35bf91df5caa67a606681519740848b0" args="(const std::string &amp;record_data) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classbadgerdb_1_1_page.html#a35bf91df5caa67a606681519740848b0">badgerdb::Page::hasSpaceForRecord</a> </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>record_data</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns true if the page has enough free space to hold the given data.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">record_data</td><td>Bytes that compose the record. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Whether the page can hold the data. </dd></dl>

<p>Definition at line <a class="el" href="page_8cpp_source.html#l00125">125</a> of file <a class="el" href="page_8cpp_source.html">page.cpp</a>.</p>
<div class="fragment"><pre class="fragment">                                                               {
  std::size_t record_size = record_data.length();
  <span class="keywordflow">if</span> (header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">num_free_slots</a> == 0) {
    record_size += <span class="keyword">sizeof</span>(PageSlot);
  }
  <span class="keywordflow">return</span> record_size &lt;= <a class="code" href="classbadgerdb_1_1_page.html#af3d324b5aae656030465e213e86e2070">getFreeSpace</a>();
}
</pre></div>
</div>
</div>
<a class="anchor" id="ad0b1e85fe7849fb767dd8c21a8053cf4"></a><!-- doxytag: member="badgerdb::Page::insertRecord" ref="ad0b1e85fe7849fb767dd8c21a8053cf4" args="(const std::string &amp;record_data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structbadgerdb_1_1_record_id.html">RecordId</a> <a class="el" href="classbadgerdb_1_1_page.html#ad0b1e85fe7849fb767dd8c21a8053cf4">badgerdb::Page::insertRecord</a> </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>record_data</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Inserts a new record into the page.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">record_data</td><td>Bytes that compose the record. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>ID of the newly inserted record. </dd></dl>

<p>Definition at line <a class="el" href="page_8cpp_source.html#l00033">33</a> of file <a class="el" href="page_8cpp_source.html">page.cpp</a>.</p>
<div class="fragment"><pre class="fragment">                                                        {
  <span class="keywordflow">if</span> (!<a class="code" href="classbadgerdb_1_1_page.html#a35bf91df5caa67a606681519740848b0">hasSpaceForRecord</a>(record_data)) {
    <span class="keywordflow">throw</span> InsufficientSpaceException(
        <a class="code" href="classbadgerdb_1_1_page.html#af55a0b44876bff4d513bdbed8bc8c5a3">page_number</a>(), record_data.length(), <a class="code" href="classbadgerdb_1_1_page.html#af3d324b5aae656030465e213e86e2070">getFreeSpace</a>());
  }
  <span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8" title="Identifier for a slot in a page.">SlotId</a> slot_number = getAvailableSlot();
  insertRecordInSlot(slot_number, record_data);
  <span class="keywordflow">return</span> {<a class="code" href="classbadgerdb_1_1_page.html#af55a0b44876bff4d513bdbed8bc8c5a3">page_number</a>(), slot_number};
}
</pre></div>
</div>
</div>
<a class="anchor" id="a8050c219873e6b1d51aec2adbea8a507"></a><!-- doxytag: member="badgerdb::Page::next_page_number" ref="a8050c219873e6b1d51aec2adbea8a507" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> <a class="el" href="classbadgerdb_1_1_page.html#a8050c219873e6b1d51aec2adbea8a507">badgerdb::Page::next_page_number</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns the number of the next used page this page in its file.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd><a class="el" href="classbadgerdb_1_1_page.html" title="Class which represents a fixed-size database page containing records.">Page</a> number of next used page in file. </dd></dl>

<p>Definition at line <a class="el" href="page_8h_source.html#l00200">200</a> of file <a class="el" href="page_8h_source.html">page.h</a>.</p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">next_page_number</a>; }
</pre></div>
</div>
</div>
<a class="anchor" id="af55a0b44876bff4d513bdbed8bc8c5a3"></a><!-- doxytag: member="badgerdb::Page::page_number" ref="af55a0b44876bff4d513bdbed8bc8c5a3" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> <a class="el" href="classbadgerdb_1_1_page.html#af55a0b44876bff4d513bdbed8bc8c5a3">badgerdb::Page::page_number</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Returns this page's number in its file.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd><a class="el" href="classbadgerdb_1_1_page.html" title="Class which represents a fixed-size database page containing records.">Page</a> number. </dd></dl>

<p>Definition at line <a class="el" href="page_8h_source.html#l00193">193</a> of file <a class="el" href="page_8h_source.html">page.h</a>.</p>
<div class="fragment"><pre class="fragment">{ <span class="keywordflow">return</span> header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a3f721c5ce9ef491fdc9d12292f2f4498">current_page_number</a>; }
</pre></div>
</div>
</div>
<a class="anchor" id="ae24e3f6076d6c0a18d4dd2014d540bab"></a><!-- doxytag: member="badgerdb::Page::updateRecord" ref="ae24e3f6076d6c0a18d4dd2014d540bab" args="(const RecordId &amp;record_id, const std::string &amp;record_data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classbadgerdb_1_1_page.html#ae24e3f6076d6c0a18d4dd2014d540bab">badgerdb::Page::updateRecord</a> </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="structbadgerdb_1_1_record_id.html">RecordId</a> &amp;&#160;</td>
          <td class="paramname"><em>record_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>record_data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Updates the record with the given ID, replacing its data with a new version. This is equivalent to deleting the old record and inserting a new one, with the exception that the record ID will not change.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">record_id</td><td>ID of record to update. </td></tr>
    <tr><td class="paramname">record_data</td><td>Updated bytes that compose the record. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="page_8cpp_source.html#l00049">49</a> of file <a class="el" href="page_8cpp_source.html">page.cpp</a>.</p>
<div class="fragment"><pre class="fragment">                                                      {
  validateRecordId(record_id);
  <span class="keyword">const</span> PageSlot* slot = getSlot(record_id.slot_number);
  <span class="keyword">const</span> std::size_t free_space_after_delete =
      <a class="code" href="classbadgerdb_1_1_page.html#af3d324b5aae656030465e213e86e2070">getFreeSpace</a>() + slot-&gt;item_length;
  <span class="keywordflow">if</span> (record_data.length() &gt; free_space_after_delete) {
    <span class="keywordflow">throw</span> InsufficientSpaceException(
        <a class="code" href="classbadgerdb_1_1_page.html#af55a0b44876bff4d513bdbed8bc8c5a3">page_number</a>(), record_data.length(), free_space_after_delete);
  }
  <span class="comment">// We have to disallow slot compaction here because we&#39;re going to place the</span>
  <span class="comment">// record data in the same slot, and compaction might delete the slot if we</span>
  <span class="comment">// permit it.</span>
  <a class="code" href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">deleteRecord</a>(record_id, <span class="keyword">false</span> <span class="comment">/* allow_slot_compaction */</span>);
  insertRecordInSlot(record_id.slot_number, record_data);
}
</pre></div>
</div>
</div>
<hr/><h2>Member Data Documentation</h2>
<a class="anchor" id="a74057ec71412352ef0aa5913bbebed25"></a><!-- doxytag: member="badgerdb::Page::DATA_SIZE" ref="a74057ec71412352ef0aa5913bbebed25" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const std::size_t <a class="el" href="classbadgerdb_1_1_page.html#a74057ec71412352ef0aa5913bbebed25">badgerdb::Page::DATA_SIZE</a> = <a class="el" href="classbadgerdb_1_1_page.html#ae92d52803502854f97309bae2c14ea55">SIZE</a> - sizeof(<a class="el" href="structbadgerdb_1_1_page_header.html">PageHeader</a>)<code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Size of page free space area in bytes. </p>

<p>Definition at line <a class="el" href="page_8h_source.html#l00118">118</a> of file <a class="el" href="page_8h_source.html">page.h</a>.</p>

</div>
</div>
<a class="anchor" id="a785a1e756d47fb7f8f3603a3fe8ffcef"></a><!-- doxytag: member="badgerdb::Page::INVALID_NUMBER" ref="a785a1e756d47fb7f8f3603a3fe8ffcef" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> <a class="el" href="classbadgerdb_1_1_page.html#a785a1e756d47fb7f8f3603a3fe8ffcef">badgerdb::Page::INVALID_NUMBER</a> = 0<code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Number of page indicating that it's invalid. </p>

<p>Definition at line <a class="el" href="page_8h_source.html#l00123">123</a> of file <a class="el" href="page_8h_source.html">page.h</a>.</p>

</div>
</div>
<a class="anchor" id="a4013fab43df72bc52931241575736353"></a><!-- doxytag: member="badgerdb::Page::INVALID_SLOT" ref="a4013fab43df72bc52931241575736353" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> <a class="el" href="classbadgerdb_1_1_page.html#a4013fab43df72bc52931241575736353">badgerdb::Page::INVALID_SLOT</a> = 0<code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Number of slot indicating that it's invalid. </p>

<p>Definition at line <a class="el" href="page_8h_source.html#l00128">128</a> of file <a class="el" href="page_8h_source.html">page.h</a>.</p>

</div>
</div>
<a class="anchor" id="ae92d52803502854f97309bae2c14ea55"></a><!-- doxytag: member="badgerdb::Page::SIZE" ref="ae92d52803502854f97309bae2c14ea55" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const std::size_t <a class="el" href="classbadgerdb_1_1_page.html#ae92d52803502854f97309bae2c14ea55">badgerdb::Page::SIZE</a> = 8192<code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p><a class="el" href="classbadgerdb_1_1_page.html" title="Class which represents a fixed-size database page containing records.">Page</a> size in bytes. If this is changed, database files created with a different page size value will be unreadable by the resulting binaries. </p>

<p>Definition at line <a class="el" href="page_8h_source.html#l00113">113</a> of file <a class="el" href="page_8h_source.html">page.h</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>bufmgr/src/<a class="el" href="page_8h_source.html">page.h</a></li>
<li>bufmgr/src/<a class="el" href="page_8cpp_source.html">page.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Friends</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Wed Jan 30 2013 14:17:57 for BadgerDB by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
